package com.atguigu.springcloud.controller;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.atguigu.springcloud.entity.CommonResult;
import com.atguigu.springcloud.entity.Payment;
import com.atguigu.springcloud.service.PaymentService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

@RestController
@Slf4j
@Api("OrderController")
@RequestMapping(value = "/consumer")
public class OrderController {
	@Autowired
	PaymentService paymentService;
	@Value("${server.port}")
	private String serverPort;
	
	@ApiOperation("查询")
	@GetMapping(value = "/get/{id}")
	public CommonResult get(@PathVariable long id) {
		log.info("调用开始：" + serverPort);
		return paymentService.getById(id);
	}
	@ApiOperation("获取当前微服务的信息")
	@GetMapping(value = "/info")
	public CommonResult info() {
		log.info("调用开始：" + serverPort);
		return	paymentService.info();
	}
}
